<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>添加自建应用</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<style type="text/css">
		.secret_container{
			width: 400px;
			margin: 0 auto;
			padding-top: 50px;
		}
		.secret_container label{
			font-size: 13px;
		}
	</style>
</head>
<body>
	<form class="layui-form" id="form1">
		<div class="secret_container">
			<div class="layui-form-item">
			  <label class="layui-form-label">应用ID</label>
			  <div class="layui-input-block">
			    <input type="text" name="agent_id" value="{$config->agent_id}" lay-verify="required" placeholder="请输入应用ID" autocomplete="off" class="layui-input">
			  </div>
			</div>
			<div class="layui-form-item">
			  <label class="layui-form-label">应用secret</label>
			  <div class="layui-input-block">
			    <input type="text" name="secret" value="{$config->secret}" lay-verify="required" placeholder="请输入应用secret" autocomplete="off" class="layui-input">
			  </div>
			</div>
			<div class="layui-form-item">
			  <div class="layui-input-block">
			    <a class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</a>
			    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
			  </div>
			</div>
		</div>
	</form>
	<script src="/layui/layui.js"></script>
	<script src="/js/ajax.js"></script>
	<script>
	//Demo
	layui.use('form', function(){
		var form = layui.form;

	  //监听提交
	  form.on('submit(formDemo)', function(data){
	  	//layer.msg(JSON.stringify(data.field));
	  	//return false;
		var formData = $('#form1').serialize();	
			myAjaxPost(false, true, '', formData, function (resp) {
				if (resp.status == 'success') {
					layer.msg(resp.msg, {
						  time: 500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
						  parent.$("#openSecret").empty();
						  var html = '';
						  html += '<img id="square_logo_url" src="'+resp.data.square_logo_url+'" width="60px" height="60px"/>';
						  html += '<span id="appName">'+resp.data.name+'</span>';
						  parent.$("#openSecret").append(html);
						  parent.layer.closeAll('iframe');
						});
				}else{
					alert(resp.msg);
				}
			});
	  });
	});
	</script>
	<script src="/cdn/jquery.js"></script>
	<script type="text/javascript">
		
	</script>
</body>
</html>